<template>
    <view class='bargain-list'>
		<view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+navH/2+'rpx'"></view>
		<view class='header'>
			
				<img :src="OSS_HOST+'img/bargain-top.png'" alt="">
			
		</view>
		<view class='list' v-for="item in data.bargainList"  @click="openSubscribe(item.id)">
			<!-- <block     > -->
				<view  class='item acea-row row-between-wrapper' hover-class='none' >
					<view class='pictrue'><image :src='item.cover_image'></image></view>
					<view class='text acea-row row-column-around'>
						<view class='line1'>{{item.name}}</view>
						<view class='num'><text class='iconfont icon-pintuan'></text>{{item.user_count}}人正在参与</view>
						<view class='money font-color'>原价: ￥<text class='price'>{{item.norm_price}}</text></view>
					</view>
					<!-- <view class="tobargain">去砍价</view> -->
					<view class='cutBnt bg-color'  ><text class='iconfont icon-kanjia'></text>参与砍价</view>
				</view>
			<!-- </block> -->
		</view>
		<view class="rule-box"  @tap="$refs.ruleModel.open()">
			砍价规则
		</view>
		<view style="height: 100rpx;"></view>
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />
		<uni-popup ref="ruleModel" type="center" custom="true" >
			<view class="content">
				<view class="title">砍价规则 </view>
				
				<view class="text">
					<view>1、瓯品商城砍价专区领取砍价任务；</view>
					<view>2、分享链接好友助力，完成任务即可领取商品；</view>
					<view>3、福利有限，每个砍价商品仅可以参与1次；</view>
					<view>4、砍价成功后，前往瓯文桃源店或公司领取（公司地址详见文末）；</view>
					<view>5、如需配送，自付10元快递费，于3日内发；</view>
					
				</view>
				<view class="btn-box">
					<view class="btn" @tap="$refs.ruleModel.close()">
						我知道了
					</view>
					
				</view>
			</view>
		</uni-popup>
    </view>
	

    
</template>

<script>
   
	import {oss_host} from '@/config/config.js';
	import store from '@/store/index.js';
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
    //获取网络状态
    import {
        mapGetters
    } from 'vuex';
    export default {
        data() {
            return {
                isSelect: false,
                //网络状态
                networkStatus: true,
				OSS_HOST: oss_host,
                //接口数据
                // bargainList:[],
                data:{
                    bargainList:[
						
						
					],
                    page:0,
                    lastPage:0,
					userInfo:{},
                },

                limit:20,
                loading:false,
                loadend:false,
               
                navH:''
            };
        },
        components: {
			uniPopup
        },
        computed: {
            //注册网络状态
            ...mapGetters(['netWorkType','loginStatus'])
        },
        onShow() {
            // this.getList()
        },

        onLoad(e) {
           
            this.getBargainList();
            // this.userInfo=e.detail

        },
		onReachBottom(){
			 // 分页 上拉加载
			 // console.log(this.data.page,this.data.lastPage)
			if (this.data.page >= this.data.lastPage) {
				// console.log(1111111)
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});
				return;
			}
		  
		  this.getBargainList();
		  
		},
        methods: {
            // 刷新的方法
            refresh() {
                this.getBargainList()
            },
             goBack(){
                uni.navigateBack({ delta: 1 })
              },
            getBargainList(){
                let that = this;
                 var opt = {
                    url: '/bargain/getBargainList',
                    data:{
                        page:++that.data.page
                    },
                    success: function(res) {
                        //console.log(res)
                        if (res.status == 1) {

                            that.data.bargainList=that.data.bargainList.concat(res.data.list)
                            that.data.page=res.data.page
                            that.data.lastPage = res.data.last_page
							that.data.userInfo = res.data.userInfo

                        } else {
                            uni.showToast({
                                icon: 'none',
                                title: res.message
                            });
                        }

                    }
                };
                that.$service.GetApi(opt)




              },
            

           
            openSubscribe(id){
				const _this = this
				if(!_this.loginStatus){
					_this.$refs.popupvLogin.open()
					return
				}
				// console.log(23)
				_this.$refer.setVilit('/pages/BargainDetails/index')
				let callback = function(url) {
				    // _this.$refs.popupvLogin.open()
				}
				var data = {
				    bargain_id: id, //
					bargainUid:_this.data.userInfo.id,
					
				}
				_this.$refer.toUrl(callback, data)
            },
            
        }
    }
</script>

<style lang="scss">
    @import "./index.scss";
</style>
